<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2024/12/24 0024
  Time: 14:41
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="UTF-8">
    <title>生产计划审核子页面</title>
    <link rel="stylesheet"  href="/bootstrap/bootstrap-5.3.3-dist/css/bootstrap.min.css" />
    <link rel="stylesheet" href="/css/ProductDesign/module(1).css" />
    <style type="text/css">

    </style>
</head>
<body style="padding: 15px 50px;background-color: #eeeeee;">
<div class="panel-heading hhead">
    <nav aria-label="breadcrumb">
        <ol class="breadcrumb">
            <span style="color: blue;">您正在做的业务是：</span>
            <li class="breadcrumb-item"><a href="#">生产管理</a></li>
            <li class="breadcrumb-item"><a href="#">生产计划管理</a></li>
            <li class="breadcrumb-item active" aria-current="page">生产计划审核</li>
        </ol>
    </nav>
</div>
<div style="margin-bottom: 2px">
    <div style="display: inline;margin-left: 78%;">
        <input type="hidden" id="userName" name="userName" value="${user.loginId}">
        <input type="radio" name="checkTag" value="2"/>未通过
        <input type="radio" name="checkTag" value="1" />通过
        <button class="btn btn-primary" id="ok">确认</button>
<%--        <button class="btn btn-primary">返回</button>--%>
    </div>
</div> <!-- 此div改用栅格来做 -->
<div id="designListBox">
    <div style="text-align: center">
        <h3>生产计划单</h3>
    </div>
    <div style="padding: 30px">
        <table class="tbl1">
            <tr>
                <td class="col1">计划单编号：</td>
                <td colspan="2" id="applyId"></td>
            </tr>
        </table>

        <table class="table table-bordered" style="margin: 15px auto;">
            <thead>
            <tr>
                <th width="200px">产品编号</th><th width="200px">产品名称</th>
                <th width="300px">描述</th><th>数量</th><th>出库单编号集合</th>
            </tr>
            </thead>
            <tbody id="template">
            <tr>
                <td id="productId"></td>
                <td id="productName"></td>
                <td id="productDescribe"></td>
                <td id="amount"></td>
                <td></td>
            </tr>
            </tbody>
        </table>

        <table class="tbl3">
            <tr>
                <td class="col1">登记人：</td>
                <td colspan="1" id="register"></td>
                <td class="col1">登记时间：</td>
                <td colspan="2" id="registerTime"></td>
            </tr>
            <tr>
                <td class="col1">审核人：</td>
                <td colspan="1"><input type="text" class="txt_under_line" id="checker"></td>
                <td class="col1">审核时间：</td>
                <td colspan="2" id="time"></td>
            </tr>
            <tr>
                <td class="col1">备注：</td>
                <td colspan="3" style="padding-top: 5px">
                    <textarea rows="4" cols="100" id="checkSuggestion"></textarea>
                </td>
            </tr>

        </table>
    </div>
</div>
<script type="text/javascript" src="/js/jquery-3.7.0.min.js"></script>
<script type="text/javascript" src="/bootstrap/bootstrap-5.3.3-dist/js/bootstrap.bundle.min.js"></script>
<script type="text/javascript" src="/js/common.js"></script>
<script type="text/javascript">
    $(function () {
        // 初始化时间
        setInterval(updateDateTime, 1000);
        // 初始化数据
        init();

        $("#ok").click(function () {
            let id = sessionStorage.getItem("id");
            let checkTag = $("input[name='checkTag']:checked").val();
            let checkSuggestion = $("#checkSuggestion").val();

            if (checkTag == null || checkTag == "") {
                alert("请选择审核结果！");
                return;
            }
            if (checkSuggestion == null || checkSuggestion == "") {
                alert("请输入审核意见！");
                return;
            }
            //获取审核人
            let checker = $("#checker").val();
            //如果审核人为空，则使用当前登录人
            if (checker == null || checker == "") {
                checker = $("#userName").val();
                $("#checker").val($("#userName").val());
            }
            let data = {}
            data.id = id;
            data.checkTag = checkTag;
            data.checker = checker;
            data.checkSuggestion = checkSuggestion;
            //data存储到sessionStorage
            sessionStorage.setItem("data",JSON.stringify(data));
            alert("提交成功！")
        })

    })
    function init() {
        let id = sessionStorage.getItem("id");
        if (id != null) {
            $.ajax({
                url: "/m-apply/getMApplyById?id=" + id,
                type: "get",
                dataType: "json",
                success: function (data) {
                    $("#applyId").text(data.applyId);
                    $("#register").text(data.register);
                    $("#registerTime").text(data.registerTime);
                    $("#productId").text(data.productId);
                    $("#productName").text(data.productName);
                    $("#productDescribe").text(data.productDescribe);
                    $("#amount").text(data.amount);
                }
            })
        }
    }
    function updateDateTime(){
        let date = new Date();
        let year = date.getFullYear();
        let month = (date.getMonth() + 1).toString().padStart(2, '0');
        let day = date.getDate().toString().padStart(2,'0');
        let hours = date.getHours().toString().padStart(2,'0');
        let minutes = date.getMinutes().toString().padStart(2,'0');
        let seconds = date.getSeconds().toString().padStart(2,'0');
        let dateTimeStr = year+"-"+month+"-"+day+" "+hours+":"+minutes+":"+seconds;
        $("#time").text(dateTimeStr);
    }
</script>
</body>
</html>
